const { Model } = require('sequelize');

module.exports = (sequelize, DataTypes) => {
  class Novel extends Model {
    static associate(models) {
      // 定义关联关系
      Novel.hasMany(models.Chapter, { foreignKey: 'novel_id' });
    }
  }
  Novel.init({
    title: DataTypes.STRING,
    author: DataTypes.STRING,
    summary: DataTypes.TEXT // 新增: 添加 summary 字段
  }, {
    sequelize,
    modelName: 'Novel',
    tableName: 'fa_novels' // 修改: 将表名从 'fa_novels' 改为 'novels'
  });
  return Novel;
};